package users.examples.app;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import users.examples.beans.Config;
import users.examples.beans.DatabaseParameters;

public class AppOneExample {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		final ApplicationContext context = new ClassPathXmlApplicationContext("users/examples/exampleOne.spring.xml");
		
		final Config config = context.getBean("config", Config.class);
		
		System.out.println(
			printAllFields(config)
		);		

	}

	private static String printAllFields(Config config) {
		final DatabaseParameters dbParms = config.getDbParms();
		return "Username: " + dbParms.getUsername() + "; Password: " + dbParms.getPassword()
			+ "; Connection: " + dbParms.getConnectionString() + "; Date Format: " 
				+ config.getDateFormat() + "; Max Cache Size: " + config.getMaxCacheSize();
	}
}
